import os
import sys

list = []
n = 1e6
while n % 7 != 0:
    list.append(int(n % 7));
    n //= 7
sum = 0
for e in list:
    sum+=e
print(sum)